<template>
  <el-dialog
    title="新增区域"
    :visible="show"
    width="30%"
  >
    <el-form ref="formRule" :model="form" label-width="80px" :rules="formRules">
      <el-form-item label="区域名称" prop="regionName">
        <el-input v-model="form.regionName" />
      </el-form-item>
      <el-form-item label="备注说明" prop="remark">
        <el-input v-model="form.remark" type="textarea" placeholder="请输入备注 (不超过40字)" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="submit ">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>

export default {
  props: {
    show: {
      type: Boolean
    }
  },
  data() {
    return {
      form: {
        regionName: '',
        remark: ''
      },
      formRules: {
        remark: [
          { required: true, message: '请填入备注', trigger: 'blur' },
          { min: 1, max: 40, message: '长度不能超过40个字', trigger: 'blur' }
        ],
        regionName: [
          { required: true, message: '请填写区域名称', trigger: 'change' }
        ]
      }
    }
  },
  created() {

  },
  methods: {
    close() {
      this.$emit('pointClose')
      this.form = {}
    },
    submit() {
      this.$refs.formRule.validate((valid) => {
        if (!valid) return
      })

      this.$emit('submit', this.form)
      this.form = {}
    }
  }

}
</script>

<style lang="scss" scoped>

</style>
